#!/usr/bin/python

# Comparison for ThreadSanitizer traces
# Author: Sergey Vartanov (me@enzet.ru)

import sys

first = open(sys.argv[1], 'r')

output = sys.argv[2]
noinoutput = sys.argv[3]
description = sys.argv[5]

output = output.replace('_SPACE_', ' ')
description = description.replace('_SPACE_', ' ')

found = 0
foundno = 0

if output == "":
	found = 1

line = first.readline()
while line != "":
	if line.find(output) != -1:
		found = 1
	if line.find(noinoutput) != -1 or line.find("Error") != -1 or line.find("Exception") != -1:
		foundno = 1
	line = first.readline()

if found and not (foundno):
	message = '    \033[0;32mSucc\033[0m    '
else:
	message = '    \033[0;31mFail\033[0m    '

sys.stdout.write(message + sys.argv[4] + " " + (" " * (40 - len(sys.argv[4]))) + description + (" " * (110 - len(description))))
